/**
 * @file tc_blinddata.c
 * @brief 盲区测试用例
 * @author  henry.cai
 * @version 1.0
 * @date 2024-12-30
 * 
 * @copyright Copyright (C) 2019 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-12-30 <td>1.0     <td>     <td>内容
 * </table>
 */
#include "tc_blinddata.h"
#ifndef NDEBUG
#include "service/include/swei_blinddata.h"
#ifndef LOG_TAG
#include "global.h"
#define LOG_TAG "TC"
#endif
#include "elog.h"

static int tc_bld_step = 0;

/**
 * @brief 盲区相关测试用例
 */
void biinddata_testcase(void)
{
    switch (tc_bld_step) {
    case 0/* nothing */:
        break;
    case 1: {/* load blind data from flash, only peek */
        uint8_t flash_data[512] = {0};
        char    print_buf[1024] = {0};
        uint32_t flash_len      = 0;
        flash_len = swei_blinddata_peek(flash_data, sizeof(flash_data));
        printf("pick from flash, len:%d, str:%s\r\n", flash_len, flash_data);
        for (uint16_t i = 0; i < flash_len; i++) {
            sprintf(print_buf + strlen(print_buf), "%02x ", flash_data[i]);
        }
        printf("pick from flash, len:%d, hex data:%s\r\n", flash_len, print_buf);
    }break;
    case 2: {/* save blind data to flash, push */
        char    *flash_data = "HelloWorld!\r\n";
        uint32_t flash_len  = strlen(flash_data);
        swei_blinddata_push((uint8_t *)flash_data, flash_len);
        printf("push to flash, len:%d, str data:%s\r\n", flash_len, flash_data);
    }break;
    case 3: {/* pop data from flash */
        uint8_t flash_data[512] = {0};
        char    print_buf[1024] = {0};
        uint32_t flash_len      = 0;
        flash_len = swei_blinddata_pop(flash_data, sizeof(flash_data));
        printf("pick from flash, len:%d, str:%s\r\n", flash_len, flash_data);
        for (uint16_t i = 0; i < flash_len; i++) {
            sprintf(print_buf + strlen(print_buf), "%02x ", flash_data[i]);
        }
        printf("pop from flash, len:%d, hex data:%s\r\n", flash_len, print_buf);
    }break;
    default:
        break;
    }

    tc_bld_step = 0;
}


#include "lettershell/shell.h"
SHELL_EXPORT_VAR(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_VAR_INT), tc_bld_step, &tc_bld_step, var for testcase blinddata);
#endif

